<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>用户管理列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/web/res/css/xadmin.css">
    <script src="/web/res/lib/layui/layui.js" charset="utf-8"></script>
    <script src="/web/res/lib/layui_exts/excel.js" charset="utf-8"></script>
    <script type="text/javascript" src="/web/res/js/xadmin.js"></script>
    <script type="text/javascript" src="/web/res/js/common.js"></script>
</head>

<body>
<div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">用户管理</a>
            <a><cite>用户管理列表</cite></a>
        </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5" type="post"  action="/after/org/detailList">
                        <input id="text" name="code" type="hidden" value="${(code)!''}">
                        <div class="layui-input-inline layui-show-xs-block">
                            <input type="text" name="loginname"  value="${loginname!''}"  placeholder="请输入登录名" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-input-inline layui-show-xs-block">
                            <input type="text" name="nick"  value="${nick!''}"  placeholder="请输入用户昵称" autocomplete="off" class="layui-input">
                        </div>

                        <div class="layui-input-inline layui-show-xs-block">
                            <select name="states">
                                <option value="">账号状态（全部）</option>
                                <#list statesMap?keys as key>
                                <option value="${key!''}" <#if states?exists && (states)?exists><#if (states)?number == key?number>selected</#if></#if> > <@mapIntString map=statesMap key=key/></option>
                    </#list>
                    </select>
                </div>
                <div class="layui-input-inline layui-show-xs-block">
                    <select name="onlineStatus">
                        <option value="">在线状态（全部）</option>
                        <#list onlineStatusMap?keys as key>
                        <option value="${key!''}" <#if onlineStatus?exists && (onlineStatus)?exists><#if (onlineStatus)?number == key?number>selected</#if></#if> > <@mapIntString map=onlineStatusMap key=key/></option>
            </#list>
            </select>
        </div>
        <div class="layui-input-inline layui-show-xs-block">
            <select name="windowTicket">
                <option value="">门票购买（全部）</option>
                <#list windowTicketMap?keys as key>
                <option value="${key!''}" <#if windowTicket?exists && (windowTicket)?exists><#if (windowTicket)?number == key?number>selected</#if></#if> > <@mapIntString map=windowTicketMap key=key/></option>
    </#list>
    </select>
</div>
注册时间：
<div class="layui-input-inline layui-show-xs-block">
    <input class="layui-input" placeholder="开始时间" autocomplete="off" value="${(startDate)!''}" name="startDate" id="startdate">
</div>
<div class="layui-input-inline layui-show-xs-block">
    <input class="layui-input" placeholder="结束时间" autocomplete="off" value="${(endDate)!''}" name="endDate" id="enddate">
</div>
<div class="layui-input-inline layui-show-xs-block">
    <button class="layui-btn"  lay-submit lay-filter="search" >
        <i class="layui-icon">&#xe615;</i>搜索
    </button>
</div>
</form>
</div>

<div class="layui-card-body"  style="overflow:auto">
    <table class="layui-table layui-form tableH" lay-size="sm"  id="tab">
        <thead>
        <tr>
            <th style="min-width:40px;">用户id</th>
            <th style="min-width:40px;">登录名</th>
            <th style="min-width:70px;">头像</th>
            <th style="min-width:40px;">用户昵称</th>
            <th style="min-width:40px;">性别</th>
            <th style="min-width:70px;">注册时间</th>
            <th style="min-width:70px;">门票</th>
            <th style="min-width:70px;">地址</th>
            <th style="min-width:70px;">是否在线</th>
            <th style="min-width:40px;">钻石</th>
            <th style="min-width:40px;">金币</th>
            <th style="min-width:40px;">账号状态</th>
            <th style="min-width:40px;">粉丝量</th>
            <th style="min-width:40px;">关注量</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <#if list?? && (list?size > 0) >
        <#list list as user>
        <tr>
            <td>${(user.id?c)!''}</td>
            <td>${(user.loginname)!''}</td>
            <td>
                <#if user.pic?? && user.pic != ''>
                <a href="javascript:void(0);" class="img_biges" title="${(user.pic)!''}">
                    <img src="${(user.pic)!''}" style=" width:35px;height:35px;"/>
                    <#else>
                    <div class="divimg"><i class="layui-icon layui-icon-picture-fine"></i>
                    </div>
                </#if>
            </td>
            <td>${(user.nick)!''}</td>
            <td><@mapIntString map=sexMap key=user.sex/></td>
            <td><#if user.createtime?exists>${(user.createtime?string("yyyy-MM-dd HH:mm:ss"))!}</#if></td>

            <td>
                <#if user.windowTicket?exists && (user.windowTicket)?number == 2>未购买
                <#elseif user.windowTicket?exists && (user.windowTicket)?number == 1>已购买
            </#if>
            <td>${(user.address)!''}</td>
            <td>
                <#if user.onlinestatus?exists && (user.onlinestatus)?number == 1>在线
                <#elseif user.onlinestatus?exists && (user.onlinestatus)?number == 2>不在线
            </#if>
            </td>
            <td>${(user.diamonds?c)!''}</td>
            <td>${(user.jinbi?c)!''}</td>
            <td><input type="checkbox" name="states" value="${user.states!''}" lay-skin="switch" lay-text="正常|禁用" {{ user.states != 1 ? 'checked' : '' }}  <#if user.states?exists && (user.states)?number == 1>checked</#if> disabled/></td>
            <td>${(user.fansnumall)!''}</td>
            <td>${(user.guanzhu)!''}</td>
            <td class="td-manage btn-centers">
                <#if user.whiteStatus?contains('1')>
                <button class="layui-btn layui-btn-xs  layui-btn-danger"  onclick="upWhiteStatus(this,'${(user.id?c)!''}',2)" >
                    <i class="layui-icon layui-icon-edit"></i>设置白名单
                </button>
            </#if>
            <#if user.whiteStatus?contains('2')>
            <button class="layui-btn layui-btn-xs  layui-btn-danger"  onclick="upWhiteStatus(this,'${(user.id?c)!''}',1)" >
                <i class="layui-icon layui-icon-edit"></i>设置普通用户
            </button>
        </#if>
        <#if user.states?contains('1')>
        <button class="layui-btn layui-btn-xs  layui-btn-danger"  onclick="xadmin.open('选择禁用时长','/after/user/selectHour?userId=${(user.id?c)}',500,300)" >
            <i class="layui-icon layui-icon-edit"></i>禁用
        </button>
        </#if>
        <#if user.states?contains('2')>
        <button class="layui-btn layui-btn-xs  layui-btn-danger"  onclick="upstate(this,'${(user.id?c)!''}',1)" >
            <i class="layui-icon layui-icon-edit"></i>解禁
        </button>
    </#if>
    <button class="layui-btn layui-btn-xs  layui-btn-normal"  onclick="xadmin.open('礼物','/after/org/giftList?id=${(user.id?c)}',800,500)" >
        <i class="layui-icon layui-icon-edit"></i>礼物详情
    </button>
    <button class="layui-btn layui-btn-xs  layui-btn-normal"  onclick="xadmin.open('音视频','/after/org/mvList?id=${(user.id?c)}',800,500)" >
        <i class="layui-icon layui-icon-edit"></i>音视频详情
    </button>
    <button class="layui-btn layui-btn-xs  layui-btn-normal"  onclick="xadmin.open('用户详情','/after/user/detail?id=${(user.id?c)}',800,500)" >
        <i class="layui-icon layui-icon-edit"></i>详情
    </button>
    <button class="layui-btn layui-btn-xs  layui-btn-normal"  onclick="xadmin.open('查看粉丝信息列表','/after/user/fensi?userid=${(user.id?c)}',1000,600)" >
        <i class="layui-icon layui-icon-edit"></i>查看粉丝
    </button>
    <button class="layui-btn layui-btn-xs layui-btn-normal" onclick="xadmin.open('个人动态','/after/user/dongtaiDetails?id=${(user.id?c)}',1200,800)" >
        <i class="layui-icon layui-icon-log"></i>个人动态
    </button>
    <button class="layui-btn layui-btn-xs layui-btn-normal" onclick="xadmin.open('发送朋友圈','/after/user/sendDongTaiGetById?id=${(user.id?c)}',800,600)" >
        <i class="layui-icon layui-icon-log"></i>发送朋友圈
    </button>
    <button class="layui-btn layui-btn-xs layui-btn-normal" onclick="xadmin.open('用户收到的礼物详情','/after/user/liwu?id=${(user.id?c)!''}',1000,600)" >
        <i class="layui-icon layui-icon-log"></i>收到礼物
    </button>
    <button class="layui-btn layui-btn-xs layui-btn-normal" onclick="xadmin.open('用户兑换记录','/after/user/dhlist?userid=${(user.id?c)!''}',1000,600)" >
        <i class="layui-icon layui-icon-log"></i>兑换记录
    </button>
    </td>
    </tr>
</#list>
<#else>
<tr>
    <td colspan="20" style="text-align: center;">暂无记录</td>
</tr>
</#if>
</tbody>
</table>
</div>
<!-- 分页条 -->
<div id="pager" style="text-align: center;"></div>
</div>
</div>
</div>
</div>
</body>
<script>


    window.onload=function(){
        layui.use(['laydate'], function () {
            let $ = layui.$;
            var laydate = layui.laydate;
            $(".img_biges").click(function(){
                var url = $(this).attr('title');
                var xbcmz =url.split(',');
                $.each(xbcmz, function (index, item) {
                    showimg(item)
                })
            });
            //执行一个laydate实例
            laydate.render({
                elem: '#startdate' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#enddate' //指定元素
            });

        });
    }
    // 删除
    function del(obj, id) {
        layui.use('layer',function () {
            let $ = layui.$;
            layer.confirm('确认要删除吗？', function (index) {
                ajaxPost($,"/role/del",{"idArray":id},function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000}, function(){
                        });
                    }
                });
            });
        });
    }

    // 账号状态修改
    function upstate(obj, id,state) {
        layui.use('layer',function () {
            let $ = layui.$;
            var text ;
            if(state == 1){
                text = "解除该账户的禁用吗？";
            }else if(state == 2){
                text = "禁用该账户吗？";
            }
            layer.confirm('确认要'+text, function (index) {
                ajaxPost($,"/after/user/upstate",{"id":id,"state":state,"hour":0},function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000}, function(){
                        });
                    }
                });
            });
        });
    }
    // 白名单
    function upWhiteStatus(obj, id,state) {
        layui.use('layer',function () {
            let $ = layui.$;
            var text ;
            if(state == 1){
                text = "设置普通用户";
            }else if(state == 2){
                text = "设置白名单用户";
            }
            layer.confirm('确认要'+text, function (index) {
                ajaxPost($,"/after/user/upWhiteStatus",{"id":id,"state":state,},function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000}, function(){
                        });
                    }
                });
            });
        });
    }
    // 会长设置
    function presidentstate(obj, id){
        layui.use('layer',function () {
            let $ = layui.$;
            layer.confirm('确认要开启会长权限吗？', function (index) {
                ajaxPost($,"/after/user/setpresident",{"userId":id},function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000}, function(){
                        });
                    }
                });
            });
        });
    }
    // 语音直播权限修改
    function upyuyinstate(obj, id,state) {
        layui.use('layer',function () {
            let $ = layui.$;
            var text ;
            if(state == 1){
                text = "开启该权限吗？";
            }else if(state == 2){
                text = "关闭该权限吗？";
            }
            layer.confirm('确认要'+text, function (index) {
                ajaxPost($,"/after/user/upyuyin",{"id":id,"state":state},function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000}, function(){
                        });
                    }
                });
            });
        });
    }

    // 视频直播权限修改
    function upvideostate(obj, id,state) {
        layui.use('layer',function () {
            let $ = layui.$;
            var text ;
            if(state == 1){
                text = "开启该权限吗？";
            }else if(state == 2){
                text = "关闭该权限吗？";
            }
            layer.confirm('确认要'+text, function (index) {
                ajaxPost($,"/after/user/upvideo",{"id":id,"state":state},function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000}, function(){
                        });
                    }
                });
            });
        });
    }


    function delAll(argument) {
        var ids = [];
        // 获取选中的id
        $('tbody input[checkid]').each(function (index, el) {
            if ($(this).prop('checked')) {
                ids.push($(this).val())
            }
        });
        var idArray = ids.toString();
        if(idArray.length == 0){
            layer.msg('请选择！', {icon: 2, time: 1000}, function(){});
            return false;
        }
        layui.use('layer',function () {
            let $ = layui.$;
            layer.confirm('确认要删除吗？', function (index) {
                $.ajax({
                    type: "POST",
                    url: "/role/del",
                    dataType: "json",
                    cache: false,
                    async: false,
                    data: {
                        "idArray":idArray
                    },
                    success: function (data) {
                        if (data.code == 0) {
                            layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                                location.reload();
                            });
                        } else {
                            layer.msg(data.msg, {icon: 2, time: 1000}, function(){
                            });
                        }
                    }
                });
            });
        });
    }
</script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['laypage', 'layer', 'form'], function(){
        let $ = layui.$;
        var laypage = layui.laypage
            ,form = layui.form
            ,layer = layui.layer;




        laypage.render({
            elem: 'pager'
            ,count: ${(splitPage.totalCount?c)!''}
            ,limit: ${(splitPage.pageSize?c)!''}
            ,curr: ${(splitPage.pageIndex?c)!''}
            ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
            ,jump: function(obj, first){
                //首次不执行
                if(!first){
                    var myform = document.forms[0];
                    // alert("formName:"+myform.id);
                    var pageIndex = document.createElement("input");
                    pageIndex.name="pageIndex";
                    pageIndex.type="hidden";
                    pageIndex.value=obj.curr;
                    myform.appendChild(pageIndex);

                    var pageSize = document.createElement("input");
                    pageSize.name="pageSize";
                    pageSize.type="hidden";
                    pageSize.value=obj.limit;
                    myform.appendChild(pageSize);
                    // myform.submit();

                    // $("button[lay-filter]")
                    // form.on('submit(button[lay-filter])', function(data){
                    //     // layer.msg(JSON.stringify(data.field));
                    //     // return false;
                    // });
                    // var submitBtn = $("button[lay-submit]");
                    // alert(submitBtn);
                    // console.log(submitBtn)
                    // layer.msg(JSON.stringify(submitBtn));

                    // $('[lay-filter="search"]').click();
                    // $('#chaxun').click();
                    $("button[lay-submit]:eq(0)").click();
                    // $("button[lay-submit]")[0].click();
                    // alert($("#formsubmit").attr("action")+"_获取数量："+obj.limit+"_页码数："+obj.curr);
                    // console.log(obj)
                }
            }
        });
    });
</script>


</html>
